#ifndef __VIMOCK_EXCEPTION_THROWER__
#define __VIMOCK_EXCEPTION_THROWER__

#include "exception_holder.hpp"

namespace vimock {
class exception_thrower {
public:
	template <typename ExceptionType>
	exception_thrower(const ExceptionType & exception) :
		holder(new default_exception_holder<ExceptionType>(exception)) {
	}
	exception_thrower(const exception_thrower & that) :
		holder(that.holder) {
	}
	void throw_exception() {
		holder->throw_exception();
	}
private:
	exception_holder holder;
	template <typename ExceptionType>
	class default_exception_holder : public _exception_holder {
	public:
		default_exception_holder(const ExceptionType & exception) :
			exception(exception) {
		}
		virtual ~default_exception_holder() {
		}
		virtual void throw_exception() {
			throw exception;
		}
	private:
		ExceptionType exception;
	};
};
}

#endif //__VIMOCK_EXCEPTION_THROWER__ 
